var xmlHttp; 

function createXMLRequest(){
	if(window.ActiveXObject){
		xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
	} else if(window.XMLHttpRequest){
		xmlHttp=new XMLHttpRequest();
	}
}

//加入/退出小组
function join(id){ 
	var classs=$("#join"+id).attr("class");
	var last=parseInt(classs.split("_")[1]);
	if(last%2==1){
		createXMLRequest();                       
		var url="/groups/join/?id="+id;
		xmlHttp.open("GET",url);
		xmlHttp.onreadystatechange=function(){
			if(xmlHttp.readyState==4 && xmlHttp.status==200){
				if(xmlHttp.responseText==1){
					$("#join"+id).attr("class","join_"+(last+1));
					//alert($("#join"+id).attr("class"))
				}
				
			}
		};
		xmlHttp.send(); 
	} else {
		if(confirm("确定要退出小组？")) {
			createXMLRequest();                       
			var url="/groups/join/?id="+id;
			xmlHttp.open("GET",url);
			xmlHttp.onreadystatechange=function(){
				if(xmlHttp.readyState==4 && xmlHttp.status==200){
					if(xmlHttp.responseText==1){
						$("#join"+id).attr("class","join_"+(last+1));
						//alert($("#join"+id).attr("class"))
					}
					
				}
			};
			xmlHttp.send(); 
		} else {
			window.location.replace("/groups");

		}
	}


}














